package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.sys.entity.DormDetailEntity;
import io.renren.modules.sys.service.DormDetailService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author Lizhiwei
 * @email 123@qq.com
 * @date 2022-10-11 19:43:49
 */
@RestController
@RequestMapping("sys/dormdetail")
public class DormDetailController {
    @Autowired
    private DormDetailService dormDetailService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("sys:dormdetail:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = dormDetailService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 获取宿舍号ids
     * @return
     */
    @GetMapping("/getDormIds")
    public R getDormIds(){
        List<Integer> list=dormDetailService.getDormIdlist();
        return R.ok().put("data", list);
    }

    /**
     * 查找宿舍区ids
     * @return
     */
    @GetMapping("/getAreaIds")
    public R getAreaIds(){
        List<String> list=dormDetailService.getAreaIds();
        return R.ok().put("data", list);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("sys:dormdetail:info")
    public R info(@PathVariable("id") Integer id){
		DormDetailEntity dormDetail = dormDetailService.getById(id);

        return R.ok().put("dormDetail", dormDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("sys:dormdetail:save")
    public R save(@RequestBody DormDetailEntity dormDetail){
		dormDetailService.save(dormDetail);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("sys:dormdetail:update")
    public R update(@RequestBody DormDetailEntity dormDetail){
		dormDetailService.updateById(dormDetail);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("sys:dormdetail:delete")
    public R delete(@RequestBody Integer[] ids){
		dormDetailService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
